//
//  DatabaseUtility.h
//  Spa Upgrade
//
//  Created by Innova on 22/2/2555.
//  Copyright (c) พ.ศ. 2555 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@interface DatabaseUtility : NSObject {
    
}
@property (nonatomic, strong, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, strong, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (nonatomic, strong) NSString *databaseName;


- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;


//init
- (id)initWithDatabaseName:(NSString *)databaseName;

//fetched function from String
- (NSArray *)fetchedResultsWithClass:(NSString *)classString withSortDescriptorString:(NSString *)sortDescriptorString;
- (NSArray *)fetchedResultsWithClass:(NSString *)classString withSortDescriptorString:(NSString *)sortDescriptorString withPredicateString:(NSString *)predicateString;

//fetched function from Object
- (NSArray *)fetchedResultsWithClass:(NSString *)classString withSortDescriptor:(NSSortDescriptor *)sortDescriptor withPredicate:(NSPredicate *)predicate;

//fetched function from ObjectID
- (NSArray *)fetchedResultsWithClass:(NSString *)classString withObjectID:(NSManagedObjectID *)objectID;

@end
